package com.polaris.live.ui.party.widget

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import com.bumptech.glide.Glide
import com.polaris.live.common.ext.formatNumberWithK
import com.polaris.live.databinding.LayoutTopMarqueenItemBinding
import com.polaris.live.resp.back_resp.ActScrollRankRoomVo
import com.polaris.live.utils.image.ImageUtils
import com.polaris.live.widget.marqueen.MarqueeFactory

/**
 * TopMarqueeView
 * @author Created by 天晴 on 2024/7/2 14:08
 * @since 1.0.0
 **/
class TopMarqueeView(context: Context) : MarqueeFactory<View, ActScrollRankRoomVo>(context) {
    private val inflater: LayoutInflater

    init {
        inflater = LayoutInflater.from(context)
    }

    override fun generateMarqueeItemView(data: ActScrollRankRoomVo): View {
        val mBinding = LayoutTopMarqueenItemBinding.inflate(inflater, null, false)
        mBinding.topTv.text = if (data.rank in 1..99) "TOP${data.rank}" else "TOP99+"
        mBinding.beansTv.text = data.score.formatNumberWithK()
        Glide.with(mContext)
            .load(ImageUtils.imgPath(data.objectUrl))
            .into(mBinding.img)
        return mBinding.root
    }
}